< previous page page_415 next page >

Page 415
Centering Forms
Many times in an application, you want to center a form (or forms) within the total screen area. Although theres a property you can use to do this, you can also write code, as shown here:
9f31265bb40b592b1929e18a47ab28e5.gif
Sub FormCenter(frmCurrent As Form)
   Dim intLeft As Integer
   Dim intTop As Integer

   intLeft = (Screen.Width / 2) _
               - (frmCurrent.Width / 2)
   intTop = (Screen.Height / 2) _
               - (frmCurrent.Height / 2)
   frmCurrent.Move intLeft, intTop
End Sub
Passing Controls to Procedures
Besides passing forms to a generic procedure, you can also pass controls to procedures or functions. This is useful when you have routines that can operate on the same types of controls, such as list boxes and combo boxes.
Examples Filename: ObjPassObj.frm
Both of the controls on the form shown in Figure 21.2 need to be filled with state names.
8160-0415a.gif
Figure 21.2
Passing objects to procedures.

 
< previous page page_415 next page >

If you like this book, buy it!